package com.feng.gaoerfu.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.feng.gaoerfu.utils.StringUtils;
import com.feng.gaoerfu.view.framework.picker.LinkagePicker;

import java.util.ArrayList;
import java.util.List;

/**
 * @time 2017/8/30 0030 9:37
 */

public class MyPickerDataProvider extends LinkagePicker.DataProvider {

    private  int num;

    public MyPickerDataProvider(int defaultNum) {
        this.num = defaultNum;
    }

    @Override
    public boolean isOnlyTwo() {
        return true;
    }


    @NonNull
    @Override
    public List<String> provideFirstData() {
        ArrayList<String> mBarsNum = StringUtils.getBarsNum(num);
        return mBarsNum;
    }

    @NonNull
    @Override
    public List<String> provideSecondData(int firstIndex) {

        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i <= firstIndex; i++) {
            if (i != 0 && i == firstIndex) {
                break;
            }
            list.add(i + "");
        }
        return list;
    }

    @Nullable
    @Override
    public List<String> provideThirdData(int firstIndex, int secondIndex) {
        ArrayList<String> thirdlist = new ArrayList<>();
        if (firstIndex == 0) {
            thirdlist.add("0");
        }

        for (int i = 0; i <= firstIndex - 1 - secondIndex; i++) {
            thirdlist.add("" + i);
        }
        return thirdlist;
    }
}
